<template>
	<view>
		<pageheader :setting="settingdata"></pageheader>
		<go-top :scrollTop="scrollTop"></go-top>
		<navigator :url="'/home/index/newdetail?id='+list[0].id" hover-class="none" class="theNews">
			<image :src="list[0].images" mode="widthFix"></image>
			<view class="clamp1 theNewtitle">{{list[0].title}}</view>
			<view class="clamp2 theNewcontent">{{list[0].desc}}</view>
			<view class="theNews_info">
				<text>{{list[0].views}}人浏览</text>
				<text class="info_time">{{list[0].createtime}}</text>
			</view>
		</navigator>
		<view class="newlist">
			<block v-for="(item,index) in list" :key="index">
				<navigator :url="'/home/index/newdetail?id='+item.id" hover-class="none" class="new_one" v-if="index>0">
					<image :src="item.images" mode="aspectFill"></image>
					<view class="new_oneinfo">
						<view class="clamp1 new_oneinfoTitle">{{item.title}}</view>
						<view class="clamp2 new_oneinfoContent">{{item.desc}}</view>
						<view class="theNews_info">
							<text>{{item.views}}人浏览</text>
							<text class="info_time">{{item.createtime}}</text>
						</view>
					</view>
				</navigator>
			</block>
		</view>
		<view class="not_more" v-if="list.length<1">
			<image src="../../static/img/wxiaoxi.png" mode="widthFix"></image>
			<view class="text">暂无消息</view>
		</view>
		<view class="nomore" v-if="nomore&&list.length>0">—— · 没有更多了 · ——</view>
	</view>
</template>

<script>
	var _this, $paginator;
	export default {
		data() {
			return {
				settingdata: {
					name: '最新公告',
					bgColor: '#fff',
					titleColor: '#000000',
					showNav: true,
					showTypes: 0,
					position: "newlist"
				},
				list: [],
				nomore: false,
				// 回到头部按钮距离
				scrollTop: 0,
			}
		},
		onLoad(e) {
			_this = this
			$paginator = new _this.$paginator(_this.$api)
			_this.getdata(true)
		},
		//监听页面滚动
		onPageScroll(res) {
			this.scrollTop = res.scrollTop
		},
		onReachBottom: function() {
			$paginator.nextPager(() => {
				_this.getdata()
			})
		},
		onShow() {},
		methods: {
			getdata: function(firstLoad = false) {
				$paginator.getData('notice', {}, (data) => {
					if (firstLoad) {
						_this.list = data.list ? data.list : []
					} else {
						_this.list = _this.list.concat(data.list)
					}
					_this.nomore = data.nomore
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.theNews {
		padding: 0 25rpx 35rpx;
		display: flex;
		flex-direction: column;
		border-bottom: 10rpx solid #f2f2f2;

		image {
			width: 690rpx;
			margin: 17rpx 10rpx 0 10rpx;
			height: 300rpx;
			border-radius: 10rpx;
		}

		.theNewtitle {
			margin: 25rpx 0 0 0;
			color: #333333;
			font-size: 30rpx;
			font-weight: bold;
		}

		.theNewcontent {
			margin-top: 27rpx;
			color: #747474;
			font-size: 28rpx;
		}

		.theNews_info {
			margin-top: 41rpx;
			display: flex;
			flex-direction: row;
			align-items: center;

			text {
				color: #A8A8A8;
				font-size: 22rpx;
			}

			.info_time {
				margin-left: 48rpx;
			}
		}
	}

	.newlist {
		margin: 8rpx 39rpx 20rpx 31rpx;
		display: flex;
		flex-direction: column;

		.new_one {
			display: flex;
			flex-direction: row;
			width: 100%;
			margin-top: 24rpx;

			image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 5rpx;
			}

			.new_oneinfo {
				display: flex;
				flex-direction: column;
				margin-left: 29rpx;
				max-width: 450rpx;

				.new_oneinfoTitle {
					margin-top: 10rpx;
					color: #333333;
					font-size: 30rpx;
					font-weight: bold;
				}

				.new_oneinfoContent {
					margin-top: 20rpx;
					color: #747474;
					font-size: 26rpx;
				}

				.theNews_info {
					margin-top: 22rpx;
					display: flex;
					flex-direction: row;
					align-items: center;

					text {
						color: #A8A8A8;
						font-size: 22rpx;
					}

					.info_time {
						margin-left: 48rpx;
					}
				}
			}
		}
	}
</style>
